package com.peng.controller;

import com.github.pagehelper.PageInfo;
import com.peng.Repo.PageStatic;
import com.peng.pojo.WelfareCastle;
import com.peng.service.WelfareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WelfareController {
    @Autowired
    private WelfareService welfareService;

    @GetMapping("/admin/getAllWelfare")
    public PageInfo<WelfareCastle> getAllWelfare(@RequestParam("name") @Nullable String name,
                                                 @RequestParam("teacherId") @Nullable Integer teacherId,
                                                 @RequestParam("typeId") @Nullable Integer typeId,
                                                 @RequestParam(name = "page", defaultValue = PageStatic.page) int page,
                                                 @RequestParam(name = "size", defaultValue = PageStatic.size) int size) {
        return welfareService.selectAllWelfareCastle(name, teacherId, typeId, page, size);
    }

    @GetMapping("/admin/updateWelfareStatus")
    public boolean updateWelfareStatus(@RequestParam(name = "status", defaultValue = "1") int status,
                                       @RequestParam(name = "id") Integer... id) {
        return welfareService.updateWelfareCastleStatus(status, id);
    }
}
